/*
 ============================================================================
 Name		: FEAppContainer.cpp
 Author	  : Gao QianXuan
 Copyright   : Your copyright notice
 Description : Application Container implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include "FEAppDirContainer.h"
#include <e32cmn.h>
#include <BARSREAD.H>
#include <FE_0xE986B88E.rsg>
#include <akniconarray.h>
#include <Icon.mbg>
#include <eikclbd.h>
#include <aknnotewrappers.h>
#include "FE.hrh"

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CFEAppDirContainer::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CFEAppDirContainer* CFEAppDirContainer::NewL(const TRect& aRect)
{
	CFEAppDirContainer* self = CFEAppDirContainer::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CFEAppDirContainer* CFEAppDirContainer::NewLC(const TRect& aRect)
{
	CFEAppDirContainer* self = new (ELeave) CFEAppDirContainer;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CFEAppDirContainer::ConstructL(const TRect& aRect)
{
	// Create a window for this application Container
	CreateWindowL();

	iDir = CFEDir::NewL();
	iFile = CFEFile::NewL();

	CreateListBoxL();
	LoadListBoxIconsL();
	LoadListBoxItemsL();

	// Set the windows size
	SetRect(aRect);

	// Activate the window, which makes it ready to be drawn
	ActivateL();
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::CFEAppDirContainer()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CFEAppDirContainer::CFEAppDirContainer()
{

}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::~CFEAppDirContainer()
// Destructor.
// -----------------------------------------------------------------------------
//
CFEAppDirContainer::~CFEAppDirContainer()
{
	delete iListbox;
	delete iDir;
	delete iFile;
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CFEAppDirContainer::Draw(const TRect& /*aRect*/) const
{
	// Get the standard graphics context
	CWindowGc& gc = SystemGc();

	// Gets the control's extent
	TRect drawRect(Rect());

	// Clears the screen
	gc.Clear(drawRect);

}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::SizeChanged()
// Called by framework when the Container size is changed.
// -----------------------------------------------------------------------------
//
void CFEAppDirContainer::SizeChanged()
{
	TRect rect = Rect();
	iListbox->SetExtent(rect.iTl, rect.Size());
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// Note: although this method is compatible with earlier SDKs, 
// it will not be called in SDKs without Touch support.
// -----------------------------------------------------------------------------
//
void CFEAppDirContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{

	// Call base class HandlePointerEventL()
	CCoeControl::HandlePointerEventL(aPointerEvent);
}

TInt CFEAppDirContainer::CountComponentControls() const
{
	return 1; // return nbr of controls inside this container
}

CCoeControl* CFEAppDirContainer::ComponentControl(TInt aIndex) const
{
	switch (aIndex)
	{
		case 0:
			return iListbox;
		default:
			return NULL;
	}
}

TKeyResponse CFEAppDirContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,
		TEventCode aType)
{
	if (iListbox != NULL)
	{
		return iListbox->OfferKeyEventL(aKeyEvent, aType);
	}
	else
	{
		return EKeyWasNotConsumed;
	}
}

// -----------------------------------------------------------------------------
// CFEAppDirContainer::HandleListBoxEventL()
// From CCoeControl. 
// Handles key and pointer events.
// -----------------------------------------------------------------------------
//

void CFEAppDirContainer::HandleListBoxEventL(CEikListBox* aListBox,
		TListBoxEvent aEventType)
{
	if ((aEventType == MEikListBoxObserver::EEventEnterKeyPressed)
			|| (aEventType == MEikListBoxObserver::EEventItemClicked))
	{
		TInt idx = aListBox->CurrentItemIndex();

		if (idx == 0)
		{
			GoBackToUpperDirL();
		}
		else
		{
			OpenL(idx);
		}
	}
}
/******************************************************************************
 * @Name:       CreateListBoxL 
 * @Author:     Gao QianXuan
 * @Purpose:    Creates the List Box object iListbox
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - A scroll bar is enabled
 ******************************************************************************/

void CFEAppDirContainer::CreateListBoxL()
{
	iListbox = new (ELeave) CAknDoubleLargeStyleListBox;
	//iListbox = new (ELeave) CAknSingleStyleListBox;
	CleanupStack::PushL(iListbox);

	iListbox->SetContainerWindowL(*this);
	iListbox->SetListBoxObserver(this);

	TResourceReader re;
	iEikonEnv->CreateResourceReaderLC(re, R_DIR_LISTBOX);
	iListbox->ConstructFromResourceL(re);
	CleanupStack::PopAndDestroy();
	CleanupStack::Pop();

	iListbox->CreateScrollBarFrameL();
	iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(
			CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
}

/******************************************************************************
 * @Name:       LoadListBoxIconsL 
 * @Author:     Gao QianXuan
 * @Purpose:    Loads the pre-compressed bmp pictures as list box icons array
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::LoadListBoxIconsL()
{
	TFileName IconFileName;
	IconFileName.Append(_L("\\resource\\apps\\Icon.mbm"));

	// Create an array of icons, reading them from the file
	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(7);
	CleanupStack::PushL(icons);

	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon1,
			EMbmIcon1_mask));
	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon2,
			EMbmIcon2_mask));
	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon3,
			EMbmIcon3_mask));
	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon4,
			EMbmIcon4_mask));
	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon5,
			EMbmIcon4_mask));
	icons->AppendL(iEikonEnv->CreateIconL(IconFileName, EMbmIcon6,
			EMbmIcon4_mask));

	CleanupStack::Pop(icons);
	iListbox->ItemDrawer()->ColumnData()->SetIconArray(icons);
}

/******************************************************************************
 * @Name:       LoadListBoxItemsL 
 * @Author:     Gao QianXuan
 * @Purpose:    This function dynamically loads all the entries specified in a 
 * 				directory to List Box and display.
 * 				Different entry types will be examed and its related icon will be
 * 				loaded.
 * 				The size of the file or directory will be calculated and displayed
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::LoadListBoxItemsL()
{
	CTextListBoxModel* model = iListbox->Model();
	model->SetOwnershipType(ELbmOwnsItemArray);
	CDesCArray* mainItemsArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());

	TBuf<256> bufItem;
	_LIT(picNo,"1");
	_LIT(textContent,"\t /.. \t \t");
	bufItem.Append(picNo);
	bufItem.Append(textContent);
	mainItemsArray->AppendL(bufItem);

	//initialise iListEntry with respect to path - undefined
	iListEntry = iDir->GetDirectoryAndFileListL(iPath);

	TInt curFile = 0;
	_LIT(Wav,".wav");
	_LIT(Bmp,".bmp");
	_LIT(Txt,".txt");
	_LIT(KSize,"\t Size KB\t");
	TChar point = '.';

	while (curFile < iListEntry->Count())
	{
		TBuf<256> bufItem;

		//find iFileExt with respect to fileBuf[curFile] - undefiend
		iCurEntry = (*iListEntry)[curFile];

		bufItem.Zero();

		//check the directory or files extention, find the icon respectively
		if (iCurEntry.IsDir())
		{
			bufItem.Append(_L("1"));
		}
		else
		{
			TPtrC ptr = iCurEntry.iName;
			TInt pos = ptr.LocateReverse(point);
			if (pos == KErrNotFound)
			{
				bufItem.Append(_L("2"));
			}
			else
			{
				ptr.Set(ptr.Mid(pos));
				iFileExt = &ptr;

				if (iFileExt->Compare(Wav) == 0)
				{
					bufItem.Append(_L("5"));
				}
				else if (iFileExt->Compare(Bmp) == 0)
				{
					bufItem.Append(_L("3"));
				}
				else if (iFileExt->Compare(Txt) == 0)
				{
					bufItem.Append(_L("4"));
				}
				else
				{
					bufItem.Append(_L("2"));
				}
			}
		}

		bufItem.Append(_L("\t"));
		bufItem.Append(iCurEntry.iName);
		bufItem.Append(_L("\t"));

		if (iCurEntry.IsDir())
		{
			/*
			 TFileName CurPath;
			 CurPath.Append(iPath);
			 CurPath.Append(iCurEntry.iName);
			 CurPath.Append(_L("\\"));

			 size = iDir->GetDirSize(CurPath);
			 */

			bufItem.Append(_L("Directory\t"));
		}
		else
		{
			TInt64 size = iCurEntry.iSize;
			TransSize(size, bufItem);
			bufItem.Append(_L("\t"));
		}

		mainItemsArray->AppendL(bufItem);

		curFile++;
	}//end of while

	iListbox->HandleItemAdditionL();
}

/******************************************************************************
 * @Name:       SetPath 
 * @Author:     Qu JunJie
 * @Purpose:    Update the current path to the user defined path 
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::SetPath(TFileName &aPath)
{
	iPath = aPath;
}

/******************************************************************************
 * @Name:       GetPath 
 * @Author:     Qu JunJie
 * @Purpose:    Returns the path of current directory 
 * @Returns:    TFileName iPath
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

TFileName CFEAppDirContainer::GetPath()
{
	return iPath;
}

/******************************************************************************
 * @Name:       GoBackToUpperDirL 
 * @Author:     Qu JunJie / Gao Qian Xuan
 * @Purpose:    Finds the parent directory from the current path and display
 *				parent directory. Root directory is Driver Page.
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::GoBackToUpperDirL()
{
	iPath.SetLength(iPath.Length() - 1);
	TInt pos = iPath.LocateReverse('\\');
	iPath = iPath.Left(pos + 1);

	if (iPath.Length() >= 3)
	{
		RefreshL();
	}
	else
	{
		iView->GetAppUi()->ActivateLocalViewL(TUid::Uid(EDriverView));
	}
}
/******************************************************************************
 * @Name:       OpenL 
 * @Author:     Qu JunJie 
 * @Purpose:    Open a directory or a text type file and display its contents.  
 * 				If user performs Open on the root directory which is the "/.." 
 * 				entry, Browser will show contents of parent directory.
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - Files orher than dirctory or txt file can not be opened
 ******************************************************************************/

void CFEAppDirContainer::OpenL(TInt aIdx)
{
	if (aIdx == 0)
	{
		GoBackToUpperDirL();
		return;
	}

	iCurEntry = (*iListEntry)[aIdx - 1];

	if (iCurEntry.IsDir())
	{
		iPath.Append(iCurEntry.iName);
		iPath.Append(_L("\\"));

		RefreshL();
	}
	else
	{
		TChar point = '.';
		TPtrC ptr = iCurEntry.iName;
		TInt pos = ptr.LocateReverse(point);
		if (pos == KErrNotFound)
		{
			TBuf<50> note;
			note.Append(_L("Cannot open this file!"));
			CAknInformationNote* infor = new (ELeave) CAknInformationNote;
			infor->ExecuteLD(note);
		}
		else
		{
			ptr.Set(ptr.Mid(pos));
			iFileExt = &ptr;

			if (!iFileExt->Compare(_L(".txt")))
			{
				TUid dirId;
				TBuf8<256> filename;
				iPath.Append(iCurEntry.iName);
				filename.Copy(iPath);
				iView->GetAppUi()->ActivateLocalViewL(TUid::Uid(EEditerView),
						dirId, filename);
			}
			else
			{
				TBuf<50> note;
				note.Append(_L("Cannot open this file!"));
				CAknInformationNote* infor = new (ELeave) CAknInformationNote;
				infor->ExecuteLD(note);
			}
		}
	}
}

/******************************************************************************
 * @Name:       Rename 
 * @Author:     Qu JunJie 
 * @Purpose:    Rename a directory 
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - Rename with duplicate names will be unsuccessful
 ******************************************************************************/

void CFEAppDirContainer::RenameL(TInt aIdx)
{
	if (aIdx == 0)
		return;

	TFileName newName;
	TBuf<10> prompt(_L("Rename:"));

	CAknTextQueryDialog* renameDlg = new (ELeave) CAknTextQueryDialog(newName,
			prompt);
	renameDlg->PrepareLC(R_EDIT_DIALOG);

	if (renameDlg->RunLD())
	{
		TBool isDuplication = TestDuplicationL(newName);
		if (!isDuplication)
		{
			TFileName oldPathAndName;
			oldPathAndName.Append(iPath);
			oldPathAndName.Append((*iListEntry)[aIdx - 1].iName);

			TFileName newPathAndName;
			newPathAndName.Append(iPath);
			newPathAndName.Append(newName);

			iDir->Rename(oldPathAndName, newPathAndName);

			RefreshL();
		}
	}
}

/******************************************************************************
 * @Name:       Delete 
 * @Author:     Qu JunJie 
 * @Purpose:    Delete a selected directory or file 
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - Function perform no action if root directory has been selected
 ******************************************************************************/

void CFEAppDirContainer::DeleteL(TInt aIdx)
{
	if (aIdx == 0)
		return;

	iCurEntry = (*iListEntry)[aIdx - 1];
	TFileName pathAndName;
	pathAndName.Append(iPath);
	pathAndName.Append((*iListEntry)[aIdx - 1].iName);

	if (iCurEntry.IsDir())
	{
		pathAndName.Append(_L("\\"));
		iDir->Delete(pathAndName);
	}
	else
	{
		iFile->Delete(pathAndName);
	}
	RefreshL();
}

/******************************************************************************
 * @Name:       Copy 
 * @Author:     Qu JunJie 
 * @Purpose:    Copys a selected directory or file to ClipBoard 
 * @Returns:    Void
 * @Parameters: TInt aIdx
 * @Remarks:    - Function perform no action if root directory has been selected
 ******************************************************************************/

void CFEAppDirContainer::Copy(TInt aIdx)
{
	if (aIdx == 0)
		return;

	isCopy = ETrue;
	iCurEntry = (*iListEntry)[aIdx - 1];
	iClipBoardName.Copy((*iListEntry)[aIdx - 1].iName);
	iClipBoardPath.Copy(iPath);
	iClipBoardPath.Append(iClipBoardName);

	if (iCurEntry.IsDir())
	{
		isDir = ETrue;
		iClipBoardPath.Append(_L("\\"));
	}
	else
	{
		isDir = EFalse;
	}
}

/******************************************************************************
 * @Name:       Move 
 * @Author:     Qu JunJie 
 * @Purpose:    Copys a selected directory or file to ClipBoard, if Paste function
 * 				were executed afterwards, this directory or file will be deleted
 * @Returns:    Void
 * @Parameters: TInt aIdx
 * @Remarks:    - Function perform no action if root directory has been selected
 ******************************************************************************/

void CFEAppDirContainer::Move(TInt aIdx)
{
	if (aIdx == 0)
		return;

	isCopy = EFalse;
	iCurEntry = (*iListEntry)[aIdx - 1];
	iClipBoardName.Copy((*iListEntry)[aIdx - 1].iName);
	iClipBoardPath.Copy(iPath);
	iClipBoardPath.Append(iClipBoardName);

	if (iCurEntry.IsDir())
	{
		isDir = ETrue;
		//iClipBoardPath.Append(_L("\\"));	
	}
	else
	{
		isDir = EFalse;
	}
}

/******************************************************************************
 * @Name:       Paste 
 * @Author:     Qu JunJie 
 * @Purpose:    Paste a previously Copied or Moved directory or file from ClipBoard
 *  			to current directory.
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - Function perform no action if ClipBoard is empty
 ******************************************************************************/

void CFEAppDirContainer::PasteL()
{
	TFileName newPathAndName;
	newPathAndName.Append(iPath);
	newPathAndName.Append(iClipBoardName);

	if (isDir)
	{
		newPathAndName.Append(_L("\\"));
		if (isCopy)
		{
			iDir->Copy(iClipBoardPath, newPathAndName);
		}
		else
		{
			iDir->Move(iClipBoardPath, newPathAndName);
		}
	}
	else //copy and move file
	{
		if (isCopy)
		{
			iFile->Copy(iClipBoardPath, newPathAndName);
		}
		else
		{
			iFile->Move(iClipBoardPath, newPathAndName);
		}
	}
	RefreshL();
}

/******************************************************************************
 * @Name:       NewFolder 
 * @Author:     Qu JunJie 
 * @Purpose:    Creates a new directory under the path of current directory
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - Duplicate names can not be used
 ******************************************************************************/

void CFEAppDirContainer::NewFolderL()
{
	TFileName newFolder;
	TBuf<24> prompt(_L("New Folder:"));
	CAknTextQueryDialog* newFolderDlg = new (ELeave) CAknTextQueryDialog(
			newFolder, prompt);
	newFolderDlg->PrepareLC(R_EDIT_DIALOG);

	if (newFolderDlg->RunLD())
	{
		TFileName path;
		path.Append(iPath);

		TBool isDuplication = TestDuplicationL(newFolder);
		if (!isDuplication)
		{
			path.Append(newFolder);
			path.Append(_L("\\"));
			iDir->NewFolder(path);
			RefreshL();
		}
	}
}

/******************************************************************************
 * @Name:       RefreshL 
 * @Author:     Qu JunJie 
 * @Purpose:    RefreshL (Delete and Reload) all the List entries under current 
 * 				directory.
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::RefreshL()
{
	DeleteAllItemsL();
	LoadListBoxItemsL();
}

/******************************************************************************
 * @Name:       GetProperties 
 * @Author:     Qu JunJie 
 * @Purpose:    Display the properties for a directory or file in an information note
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::GetPropertiesL(TInt aIdx)
{
	if (aIdx == 0)
		return;

	iCurEntry = (*iListEntry)[aIdx - 1];
	TFileName pathAndName;
	pathAndName.Append(iPath);
	pathAndName.Append((*iListEntry)[aIdx - 1].iName);

	TInt64 size;
	TBuf<100> properties;
	properties.Append((*iListEntry)[aIdx - 1].iName);
	properties.Append(_L("\n"));

	if (iCurEntry.IsDir())
	{
		pathAndName.Append(_L("\\"));

		size = iDir->GetDirSize(pathAndName);
	}
	else
	{
		size = (*iListEntry)[aIdx - 1].iSize;
	}

	TransSize(size, properties);
	properties.Append(_L("\n"));

	iFile->LoadFileProperties(pathAndName, properties);

	CAknInformationNote* infor = new (ELeave) CAknInformationNote;
	infor->ExecuteLD(properties);
}

/******************************************************************************
 * @Name:       TransSize 
 * @Author:     Qu JunJie 
 * @Purpose:    Transform a calculated size unit from B to KB, MB or GB
 * @Returns:    Void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::TransSize(TInt64 aSize, TDes &aBuf)
{
	TInt unit = 0;
	while (aSize > 1024)
	{
		aSize /= 1024;
		unit++;
	}

	aBuf.AppendNum(aSize);

	switch (unit)
	{
		case 0:
		{
			aBuf.Append(_L(" B"));
			break;
		}
		case 1:
		{
			aBuf.Append(_L(" KB"));
			break;
		}
		case 2:
		{
			aBuf.Append(_L(" MB"));
			break;
		}
		case 3:
		{
			aBuf.Append(_L(" GB"));
			break;
		}
	}
}

/******************************************************************************
 * @Name:       GetListBoxCtrl 
 * @Author:     Qu JunJie 
 * @Purpose:    Returns the Entry List under current directory
 * @Returns:    CAknDoubleLargeStyleListBox iListbox
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

CAknDoubleLargeStyleListBox *CFEAppDirContainer::GetListBoxCtrl()
{
	return iListbox;
}

/******************************************************************************
 * @Name:       GetCurItem 
 * @Author:     Qu JunJie 
 * @Purpose:    Loads the item Entry specified by the index under current directory
 * 				and checks if it is of type Directory.
 * @Returns:    void
 * @Parameters: TInt aIdx
 * 				TBool &aIsDir
 * 				TFileName &aItem
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::GetCurItem(TInt aIdx, TBool &aIsDir, TFileName &aItem)
{
	TEntry curEntry;
	curEntry = (*iListEntry)[aIdx - 1];

	aIsDir = curEntry.IsDir();

	aItem.Append(iPath);
	aItem.Append(curEntry.iName);
	aItem.Append(_L("\\"));
}

/******************************************************************************
 * @Name:       DeleteAllItemsL 
 * @Author:     Qu JunJie 
 * @Purpose:    Delete all the item entries under current directory
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::DeleteAllItemsL()
{
	while (iListbox->Model()->NumberOfItems() > 0)
	{
		CDesCArray* itemArray = STATIC_CAST(CDesCArray*, iListbox->Model()->ItemTextArray());
		itemArray->Delete(0);
		AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(iListbox, 0,
				ETrue);
	}
}

/******************************************************************************
 * @Name:       SetView 
 * @Author:     Qu JunJie 
 * @Purpose:    Set the Explorer view to user defined view
 * @Returns:    void
 * @Parameters: None
 * @Remarks:    - 
 ******************************************************************************/

void CFEAppDirContainer::SetView(CFEAppDirView *aView)
{
	iView = aView;
}

/******************************************************************************
 * @Name:       TestDuplication 
 * @Author:     Qu JunJie 
 * @Purpose:    Checks for any duplicate names exist under current directory 
 * @Returns:    TBool isDuplication
 * @Parameters: TFileName &newName
 * @Remarks:    - 
 ******************************************************************************/

TBool CFEAppDirContainer::TestDuplicationL(TFileName &newName)
{
	TBool isDuplication = EFalse;
	for (TInt i = 0; i < iListEntry->Count(); i++)
	{
		iCurEntry = (*iListEntry)[i];
		if (newName.CompareF(iCurEntry.iName) == 0)
		{
			isDuplication = ETrue;

			TBuf<50> note;
			note.Append(_L("Duplication of name!"));
			CAknInformationNote* infor = new (ELeave) CAknInformationNote;
			infor->ExecuteLD(note);

			break;
		}
	}

	return isDuplication;
}

// End of File
